package tut.collection.code;
import java.util.HashMap;
import java.util.Iterator;

public class MapTest2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		HashMap<SoccerPlayer, String> hashMap = new HashMap<SoccerPlayer, String>();
		hashMap.put(new SoccerPlayer("a", "b"), "1");
		hashMap.put(new SoccerPlayer("c", "d"), "2");
		hashMap.put(new SoccerPlayer("a", "b"), "3");

		if(hashMap.containsKey(new SoccerPlayer("a", "b"))) System.out.println("1");
		else System.out.println("11");
		if(hashMap.containsKey(new SoccerPlayer("a", "ab"))) System.out.println("2");
		else System.out.println("22");
		MapTest2.printMap(hashMap);
		System.out.println(hashMap);
	}



	public static void printMap(HashMap<SoccerPlayer, String> map) {
		Iterator<SoccerPlayer> i = map.keySet().iterator();
		while (i.hasNext()) {
			SoccerPlayer oKey = (SoccerPlayer) i.next();
			String oVal = (String) map.get(oKey);
			System.out.println(oKey.toString() + ", " + oVal);
		}

		System.out.println("===============");
	}

}
